package com.yxym.extend_.improve;

public class ExtendsTheory {
    public static void main(String[] args) {
        Son son = new Son();
        //子类是否有该类属性
        //如果子类有这属性，就返回该属性
        //子类没有该属性就继续向上返回父类该属性
        //以此类推
        System.out.println(son.hobby + "\t" + son.name );
        System.out.println(son.getAge());
        //System.out.println(son.age);
    }
}
class GrandPa{
    String name = "爷爷";
    String hobby = "写作" ;
    int age = 80;
}
class Father extends GrandPa{
    String name = "爸爸";
    private  int age = 50;
    public int getAge(){
        return age;
    }
}
class Son extends Father{
    String name = "儿子";
}
